package tiruvury.InterviewPrep.GenericAlgosTests;

import tiruvury.InterviewPrep.Generic.GenericAlgos;

public class GenericAlgosTests
{

	public static void main(String[] args)
	{
		// Print angle between hour and minute hands of clock given time in hrs
		// and mins
		int hrs = 10;
		int mins = 14;
		double angleBetweenHands = GenericAlgos.FindAngleBetweenHands(hrs, mins);
		System.out.println("-- The angle between hands at " + hrs + ":" + mins + " is: " + angleBetweenHands + " degrees.");
		System.out.println();

		int board[][] =
		{
		{ 0, 0, 1 },
		{ 0, 1, 0 },
		{ 1, 0, 0 } };
		GenericAlgos.CheckTicTacToeWin(board);
		System.out.println();

		int num = 945;
		String romanNotation = GenericAlgos.GetRomanNotation(num);
		System.out.println(num + " in Roman Notation: " + romanNotation + "\n");

		romanNotation = "XLIV";
		num = GenericAlgos.RomanToInt(romanNotation);
		System.out.println(romanNotation + " in Integer Notation: " + num + "\n");

		// Given n and steps of 1, 2 or 3, print all possible step
		// configurations
		int n = 6;
		GenericAlgos.GetStepsConfiguration(n);
		System.out.println("Num Step Configurations: " + GenericAlgos.GetNumSteps(n, new int[n]));

		// Shuffle Cards
		GenericAlgos.ShuffleCards();

		int[] arr =
		{ 0, 1, 5, 9, 10, 11, 19, 20, 21, 50, 51, 99, 100, 101, 111, 120, 131, 215, 299, 500, 780, 999, 1000, 1001, 1018, 1030, 1051, 1100, 1250, 1319, 1456, 9999, 10000, 10500, 20450, 999999 };
		for (int i = 0; i < arr.length; i++)
		{
			System.out.println(arr[i] + " in words is: " + GenericAlgos.GetNumInWords(arr[i]));
		}

		int[] num1 =
		{ 3, 4, 7 };
		GenericAlgos.printMultiples(num1, 1, 100);

		System.out.println();
		String numStr = "123";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "123";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "  00123";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "+5.0";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "-5.-2";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "  -523+7";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "-5237";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "+2.";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "-3.1";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "5.-2";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "1.2.3";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = ".1";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = ".123";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");
		numStr = "34 45";
		System.out.println(numStr + (GenericAlgos.isStringANumber(numStr) ? " is " : " is not ") + "a number");

		System.out.println();
		String numStr1 = "1001";
		int radix = 16;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "1001";
		radix = 10;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "1001";
		radix = 8;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "1001";
		radix = 2;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "99";
		radix = 16;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "99";
		radix = 10;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "99";
		radix = 8;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "99";
		radix = 2;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "a1b";
		radix = 16;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "a1b";
		radix = 10;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "a1b";
		radix = 8;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		numStr1 = "a1b";
		radix = 2;
		System.out.println("Integer value of " + numStr1 + " to the base " + radix + " is: " + GenericAlgos.getIntegerValue(numStr1, radix));

		// String postFixStr = new String("23*46/+");
		String postFixStr = new String("362-*");
		System.out.println(postFixStr + " evaluates to: " + GenericAlgos.RPNCalculator(postFixStr));
	}
}
